import axios from '@/libs/api.request'
import { setToken } from '@/libs/util'
export const login = ({
  userName,
  password
}) => {
  const data = {
    mobile: userName,
    password
  }
  return axios.request({
    url: 'api/user/access/login',
    data,
    method: 'post'
  })
}

export const getUserInfo = (token) => {
  return axios.request({
    url: 'api/user/access/current',
    method: 'get',
    headers: {
      'Authorization': 'Bearer ' + token
    }
  })
}

export const logout = (token) => {
  setToken('')
  return axios.request({
    url: 'api/user/access/logout',
    method: 'post'
  })
}
